package DataBase;

import java.sql.PreparedStatement;
import java.util.Vector;

public class GetOrdersByID {

	private Vector<Vector> orders;
	private Vector<Integer> ids;

	public GetOrdersByID(Vector<Integer> ids) {
		this.ids = ids;
	}

	public Vector<Vector> getOrders() {
		SQLConnection sc = new SQLConnection();
		String sql = "SELECT o.amount, o.price, o.date, i.Iname, "
				+ "i.IUnit_of_measure, s.suppName, s.suppFax, s.suppCity,s.suppStreet, "
				+ "s.suppPhoneNo, s.suppPhoneNo2, s.suppCellNo  "
				+ "FROM orders o JOIN item i ON i.Iid = o.item_id JOIN supplier s ON s.suppID = o.supplier_id WHERE order_id = "
				+ ids.get(0);

		for (int id : ids) {
			if (id != ids.get(0))
				sql += " OR order_id = " + id;
		}
		sql += ";";

		try {
			PreparedStatement ps = sc.getConnection().prepareStatement(sql);
			sc.getConnection().close();
		} catch (Exception e) {
			e.printStackTrace();
		}

		return orders;
	}
}
